<%@include file="/page/tag.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<!--框架必需start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/jquery.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/language/cn.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/framework.js"></script>
<link href="${ctp}/QUI/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link href="${ctp}/QUI/libs/skins/lightBlue/style.css" rel="stylesheet" type="text/css" id="theme" themeColor="lightBlue"/>
<!--框架必需end-->

<!--数据表格start-->
<script src="${ctp}/QUI/libs/js/table/quiGrid.js" type="text/javascript"></script>
<!--数据表格end-->

<!--布局控件start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/nav/layout.js"></script>
<!--布局控件end-->

<!--箭头分页start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/nav/pageArrow.js"></script>
<!--箭头分页end-->

<!--树组件start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/tree/ztree/ztree.js"></script>
<link href="${ctp}/QUI/libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
<!--树组件end -->

<!-- 日期选择框start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->

<style>
.right_border{
	border-right: 1px solid;
}

.a_button{
    display: inline-block;
    width: 24px;
	height: 20px;
    line-height: 22px;
    background: url("${ctp}/QUI/libs/skins/lightBlue/form/btn_bg.jpg") 0px 0px repeat scroll transparent;
    border: 1px solid rgb(157, 194, 246);
    padding: 1px 6px;
}
.a_button:hover {
    background-image: url(${ctp}/QUI/libs/skins/lightBlue/form/btn_bg_hover.jpg)!important;
    border: 1px solid #af923f!important;
}
a{TEXT-DECORATION:none; color:#000;}
</style>
</head>
<body style="background-color:#ffffff;">

<div id="layout1">
        <div id="leftCon" position="left" style="" panelTitle="组织机构">
        
        	<div class="orgTreeContainer">
        		<ul id="tree-1" class="ztree"></ul>
        	</div>
        </div>
        
        <div id="centerCon" position="center" style="">
        
			<div class="box2" panelTitle="条件查询" id="searchPanel" startState="open">
				<form id="searchF">
					<input type="hidden" name="pageNo" value="1"/>
					<input type="hidden" name="pageSize" value="20"/>
					<input id="h_orderBy" type="hidden" name="orderBy" value="sortIndex"/>
					<input id="h_order" type="hidden" name="order" value="desc"/>
					
					<table class="tableStyle" >
						<tr>
							<td>
								<div style="width: 35px;">名字:</div>
							</td>
							<td colspan="3">
								<input type="text" style="width: 80%" name="filter_LIKES_userName"/>
							</td>
							
							<td>
								<div style="width: 54px;">手机号码:</div>
							</td>
							<td>
								<input type="text" style="width: 90%;" name="filter_LIKES_userPhone"/>
							</td>
						</tr>
						
						<tr>
							<td>
								<div style="width: 35px;">工号:</div>
							</td>
							<td >
								<input type="text" style="width: 70%;"  name="filter_LIKES_userCode"/>
							</td>
							
							<td>
								<div style="width: 35px;">账号:</div>
							</td>
							<td >
								<input type="text" style="width: 70%;"  name="filter_LIKES_userAccount"/>
							</td>
							
							<td colspan="2" style="text-align: center;">
								<input type="button" value="查询" onclick="searchFF()" />
								<input type="button" value="刷新" onclick="reflushList()" />
							</td>
						</tr>
						
					</table>
				</form>
			</div> 
			
			<div class="padding_right5">
				<div id="maingrid">
			    </div>
			</div>	
			
			<div id="pageContent" style="height:35px;"></div> 	
      </div>
        
    </div> 

<script type="text/javascript" src="${ctp}/js/list.js"></script>
<script type="text/javascript" src="${ctp}/js/httpUtil.js"></script> 
<script type="text/javascript" src="${ctp}/js/dateUtil.js"></script> 
<script type="text/javascript">
var g_pageNo = 1;
var g_pageSize = 20;
//数据表格使用
var g;
var gridData;

var selectedIdsArr = new Array(), selectedNamesArr = new Array();
function initComplete(){
	
	var ids = "${param.ids}".split(",");
	var names = "${param.names}".split(",");
	
	for(var i in ids){
		selectedIdsArr.push(ids[i]);
		selectedNamesArr.push(names[i]);
	}
		
	getLeftComparyInfo();
	g = $("#maingrid").quiGrid({
		columns: [ 
		          { display: 'id', isAllowHide: false, name: 'sysUserInfoId',hide:true },
		          { display: '名字',  name: 'userName',  isAllowHide: false,   align: 'center',  width:"20%" },
		          { display: '工号',  name: 'userCode',  isAllowHide: false,   align: 'center',  width:"15%" },
		          { display: '手机号码',  name: 'userPhone',  isAllowHide: false,   align: 'center',  width:"20%" },
		          { display: '账号',  name: 'userAccount',  isAllowHide: false,   align: 'center',  width:"20%" },
		          { display: '创建时间', name: 'createTime', isAllowHide: false, align: 'center',  width:"20%", type:"date" }
		          ], 
		          data:[],
		          sortName: 'sortIndex',
		          sortOrder: 'desc',
		          rownumbers:true,
		          percentWidthMode:false,
		          dataAction:'dataAction',
		          enabledSort:true,
		          checkbox:true,
		          usePager: false,
		          height: '95%',
		          width:"100%",
		          frozen:false,
		          isChecked:checkedHandler,
		          toolbar:{
		        	  items:[
		        	         ]
		          }, 
		          onChangeSort : function(){
		        	  $("#h_orderBy").val(g.options.sortName);
		        	  $("#h_order").val(g.options.sortOrder);
		        	  var data = $("#searchF").serialize();
		        	  getData(g.options.url, data);
		        	  return false;
		          },
		          onDblClickRow:function(rowdata, rowindex, rowDomElement){
		        	  //onView(rowdata.sysUserInfoId);
		          },
		          onCheckAllRow:function(checked, grid, element){
			        	 var gdata = g.getData();
			        	 if(checked){
			        		 for(var i in gdata){
				        		  selectedIdsArr.push(gdata[i].sysUserInfoId);
				        		  selectedNamesArr.push(gdata[i].userName);
				        	  } 
			        	  } else{
			        		  for(var i in gdata){
				        		  removeArr(selectedIdsArr, gdata[i].sysUserInfoId);
				        		  removeArr(selectedNamesArr, gdata[i].userName);
				        	  }
			        	  }
		          },
		          onCheckRow:function(checked, rowdata, rowindex, rowDomElement){
		        	  if(checked){
		        		  selectedIdsArr.push(rowdata.sysUserInfoId);
		        		  selectedNamesArr.push(rowdata.userName);
		        	  } else{
		        		  removeArr(selectedIdsArr, rowdata.sysUserInfoId);
		        		  removeArr(selectedNamesArr, rowdata.userName);
		        	  }
		          }
		          
	});
}

$(function(){
	g.options.url = "${ctp}/sysUserInfo/sysUserInfo_list.do";
	g.options.data = {
			"pageNo": g_pageNo,
			"pageSize": g_pageSize,
			"orderBy": "sortIndex",
			"order": "asc"
	};
	getData(g.options.url, g.options.data);
});

function searchFF(){
	var data = $("#searchF").serialize();
	getData(g.options.url, data);
}

var leftTree, currTreeNode=undefined;
//左侧部门树
function getLeftComparyInfo(){
	$("#layout1").layout({ leftWidth: 150,onEndResize:function(){
	  	g.resetWidth();
	  }});
	
	$.get("${ctp}/sysUserInfo/getUserCompanyTreeJson.do", function(data){
		leftTree = $.fn.zTree.init($("#tree-1"), {callback:{onClick:onClickTree}}, data.list);
		if(currTreeNode != undefined){
			leftTree.selectNode(currTreeNode);
		}
      });
}

function onClickTree(event, treeId, treeNode, clickFlag){
	currTreeNode = treeNode;
	if(currTreeNode.flag == 1){
		var data = {
				"pageNo": 1,
				"pageSize": g_pageSize,
				"orderBy": "sortIndex",
				"order": "asc",
				"filter_EQS_sysDept.sysDeptId":currTreeNode.id
		};
		getData(g.options.url, data);
	}
}


function checkedHandler(rowdata){
	if(selectedIdsArr.length <1){
		return false;
	}
	for(var i in selectedIdsArr){
		if(selectedIdsArr[i] == rowdata.sysUserInfoId){
			return true;
		}
	}
	return false;
}

function removeArr(arr, e) { 
    for(var i in arr){
    	if(arr[i] == e){
    		arr.splice(i, 1);
    		return ;
    	}
    }
} 

</script> 

</body>
</html>
